﻿package com.gengine.media.core.play
{
    import com.gengine.media.events.*;

    public class MediaPlayCore extends Object implements IMediaPlayCore
    {
        protected var _paused:Boolean = false;
        protected var _playing:Boolean = false;
        protected var _stopped:Boolean = true;
        protected var _url:String;
        protected var _mediaData:Object;
        protected var _volume:Number = 1;
        protected var _mute:Boolean = false;
        protected var _bufferTime:Number = 1000;
        protected var _buffering:Boolean = false;
        protected var _bufferPercentage:Number = 0;
        protected var _loadPercentage:Number = 0;
        protected var _playheadTime:Number = 0;
        protected var _totalTime:Number = 0;
        protected var _callback:Object;

        public function MediaPlayCore(param1:String = null, param2:Number = 1000, param3:Object = null)
        {
            this._url = param1;
            this._bufferTime = param2;
            this._callback = param3;
            return;
        }// end function

        public function get paused() : Boolean
        {
            return this._paused;
        }// end function

        public function get playing() : Boolean
        {
            return this._playing;
        }// end function

        public function get stopped() : Boolean
        {
            return this._stopped;
        }// end function

        public function get url() : String
        {
            return this._url;
        }// end function

        public function get mediaData() : Object
        {
            return this._mediaData;
        }// end function

        public function get volume() : Number
        {
            return this._volume;
        }// end function

        public function set volume(param1:Number) : void
        {
            this._volume = param1;
            return;
        }// end function

        public function get mute() : Boolean
        {
            return this._mute;
        }// end function

        public function get bufferTime() : Number
        {
            return this._bufferTime;
        }// end function

        public function get bufferPercentage() : Number
        {
            return this._bufferPercentage;
        }// end function

        public function get loadPercentage() : Number
        {
            return this._loadPercentage;
        }// end function

        public function get playheadTime() : Number
        {
            return this._playheadTime;
        }// end function

        public function get totalTime() : Number
        {
            return this._totalTime;
        }// end function

        public function get playheadPercentage() : Number
        {
            return this.totalTime == 0 ? (0) : (this.playheadTime / this.totalTime);
        }// end function

        public function get buffering() : Boolean
        {
            return this._buffering;
        }// end function

        public function play() : void
        {
            this._playing = true;
            var _loc_1:* = !this._playing;
            this._stopped = !this._playing;
            this._paused = _loc_1;
            return;
        }// end function

        public function pause() : void
        {
            this._paused = true;
            var _loc_1:* = !this._paused;
            this._stopped = !this._paused;
            this._playing = _loc_1;
            return;
        }// end function

        public function resume() : void
        {
            return;
        }// end function

        public function stop() : void
        {
            this._stopped = true;
            var _loc_1:* = !this._stopped;
            this._paused = !this._stopped;
            this._playing = _loc_1;
            return;
        }// end function

        public function seek(param1:Number = 0) : void
        {
            return;
        }// end function

        public function seekPercent(param1:Number = 0) : void
        {
            return;
        }// end function

        public function dispose() : void
        {
            if (this._callback)
            {
                if (this._callback.hasOwnProperty("onMediaEvent"))
                {
                    this._callback.onMediaEvent = null;
                }
                this._callback = null;
            }
            return;
        }// end function

        protected function callbackFunction(param1:String, param2:String = null) : void
        {
            if (this._callback)
            {
                if (this._callback.onMediaEvent)
                {
                    this._callback.onMediaEvent(new MediaPlayEvent(param1, this, param2));
                    ;
                }
            }
            return;
        }// end function

    }
}
